<%--
  Created by IntelliJ IDEA.
  User: 67380
  Date: 2016/10/25
  Time: 8:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/bootstrap-responsive.min.css" />
    <%--<link rel="stylesheet" href="/css/uniform.css" />--%>
    <link rel="stylesheet" href="/css/select2.css" />
    <link rel="stylesheet" href="/css/matrix-style.css" />
    <link rel="stylesheet" href="/css/matrix-media.css" />
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
    <style type="text/css">
        .datatablebtn{
            float: right;
            margin-top: 3px;
        }
        select{
            margin-bottom: 0px;
        }
    </style>
</head>
<body style="background-color: transparent">
<div class="widget-box">
    <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
        <h5>教师管理</h5>
        <button class="btn btn-info datatablebtn" onclick="exportstu()">EXCEL导出</button>
    </div>
    <div class="widget-content nopadding">
        <table class="table table-bordered data-table" style="width: 100%">
            <thead>
            <tr>
                <th>工号</th>
                <th>姓名</th>
                <th>专业</th>
                <th>第一志愿</th>
                <th>第二志愿</th>
                <th>第三志愿</th>
                <th>导师</th>
                <th></th>

            </tr>
            </thead>
            <c:forEach items="${studentList}" var="student">
                <tr>
                    <td >${student.sticket}</td>
                    <td >${student.sname}</td>
                    <td >${student.major.cname}</td>
                    <c:if test="${student.stu_desire.firstDesire==null}">
                        <td></td>
                    </c:if>


                    <c:forEach items="${student.teachers}" var="i">
                        <c:if test="${i.tid==student.stu_desire.firstDesire}">
                            <td>${i.tname}&nbsp;
                                <c:if test="${student.stu_desire.firstOptty==0}">
                                    <span style="color:red;">未被选中</span>
                                </c:if>
                                <c:if test="${student.stu_desire.firstOptty!=0}">
                                    <span style="color:green;">被选中 ${student.stu_desire.firstOptty}</span>
                                </c:if>
                            </td>
                        </c:if>
                    </c:forEach>
                    <c:if test="${student.stu_desire.secondDesire==null}">
                        <td></td>
                    </c:if>
                    <c:forEach items="${student.teachers}" var="i">
                        <c:if test="${i.tid==student.stu_desire.secondDesire}">
                            <td>${i.tname}&nbsp;
                                <c:if test="${student.stu_desire.secondOptty==0}">
                                    <span style="color:red;">未被选中</span>
                                </c:if>
                                <c:if test="${student.stu_desire.secondOptty!=0}">
                                    <span style="color:green;">被选中 ${student.stu_desire.secondOptty}</span>
                                </c:if>
                            </td>
                        </c:if>
                    </c:forEach>
                    <c:if test="${student.stu_desire.thirdDesire==null}">
                        <td></td>
                    </c:if>
                    <c:forEach items="${student.teachers}" var="i">
                        <c:if test="${i.tid==student.stu_desire.thirdDesire}">
                            <td>${i.tname}&nbsp;
                                <c:if test="${student.stu_desire.thirdOptty==0}">
                                    <span style="color:red;">未被选中</span>
                                </c:if>
                                <c:if test="${student.stu_desire.thirdOptty!=0}">
                                    <span style="color:green;">被选中 ${student.stu_desire.thirdOptty}</span>
                                </c:if>
                            </td>
                        </c:if>
                    </c:forEach>
                    <form action="/de" method="post" onsubmit="return sucheck()">
                    <td >
                        <input type="hidden" name="opt" value="0">
                        <input type="hidden" name="sid" value="${student.sid}">
                        <select name="tid">
                            <c:if test="${empty student.steacherid}">
                                <option value="-1">未选定</option>
                            </c:if>
                            <c:forEach items="${student.teachers}" var="st">
                                <c:if test="${student.steacherid==st.tid}">
                                    <option selected value="${st.tid}">${st.tname}(${st.tsuiplus})</option>
                                </c:if>
                                <c:if test="${student.steacherid!=st.tid}">
                                    <c:if test="${st.tsuiplus<=0}">
                                        <option disabled value="${st.tid}">${st.tname}(${st.tsuiplus})</option>
                                    </c:if>
                                    <c:if test="${st.tsuiplus>0}">
                                        <option  value="${st.tid}">${st.tname}(${st.tsuiplus})</option>
                                    </c:if>
                                </c:if>
                            </c:forEach>
                            <option disabled>—————————————————</option>
                        <c:forEach items="${teacherList}" var="t">

                                <c:if test="${t.major.college==student.major.college and t.tid!=student.stu_desire.firstDesire and t.tid!=student.stu_desire.secondDesire and t.tid!=student.stu_desire.thirdDesire}">
                                    <c:if test="${student.steacherid==t.tid}">
                                        <option selected value="${t.tid}">${t.tname}(${t.major.cname}|${t.tsuiplus})</option>
                                    </c:if>
                                    <c:if test="${student.steacherid!=t.tid}">
                                        <c:if test="${t.tsuiplus<=0}">
                                            <option disabled  value="${t.tid}">${t.tname}(${t.major.cname}|${t.tsuiplus})</option>
                                        </c:if>
                                        <c:if test="${t.tsuiplus>0}">
                                            <option  value="${t.tid}">${t.tname}(${t.major.cname}|${t.tsuiplus})</option>
                                        </c:if>

                                    </c:if>
                                </c:if>

                        </c:forEach>
                    </select> </td>
                    <td ><button type="submit" class="btn btn-mini btn-primary" >选定</button> </td>
                    </form>
                </tr>

            </c:forEach>
        </table>
    </div>

</div>

</body>
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery.ui.custom.js"></script>
<script src="/js/bootstrap.min.js"></script>
<%--<script src="/js/jquery.uniform.js"></script>--%>
<script src="/js/select2.min.js"></script>
<script src="/js/jquery.dataTables.min.js"></script>
<script src="/js/matrix.js"></script>
<script src="/js/matrix.tables.js"></script>

<script>
    $('.stutable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "sDom": '<""l>t<"F"fp>'
    });
    function excelimport() {
        $("#excelimport").click();

    }
    $("#excelimport").change(function () {
        $("#studentform button").click();
    })
    function deleterow(carid) {
        if(confirm("是否确定删除")){
            window.location.href="/studelete?cardid="+carid;
        }
    }
    function detail(carid) {

        window.location.href="/studetail?cardid="+carid;

    }
    function btn(sid,tid) {
        window.location.href="/de?sid="+sid+"&tid="+tid+"&opt=0";
    }
    function sucheck() {
        if(confirm("确定如此分配吗"))
                return true;
        return false;
    }
    function exportstu() {
        window.location.href="exportStuExcel?college=能源与机械工程学院";
    }
</script>

</html>
